<template>
	<view class="batch" @touchmove.stop.prevent="moveHandle" @click="close" v-if="show">
			<view class="disalog-box">
				<view class="title-box">
					<view class="title">
						消息通知即将发送
					</view>
				</view>
				<view class="disalog-content">
					<view class="content-item">
						推送方式 {{informData.pushMode}}
					</view>
					<view class="content-item">
						<text>通知对象</text>
						<view class="content-item-textarea">
							<view v-for="item,index in informData.noticeObjTemps" :key="item.objId" style="line-height: 38rpx;">{{item.objName}}</view>
						</view>
					</view>
					<view class="content-item">
						<text>通知内容</text>
						<view class="content-item-textarea">{{informData.templateName}}</view>
					</view>
				</view>
				<view class="bottomBtn" @click="notification">
					<view class="bottomBtn-text">修改并发送（倒计时{{countDownNum}}s）</view>
				</view>	
			</view>
	</view>
</template>

<script>
	import * as api from '@/utils/api.js';
	export default {
		props:{
			show:{
				type:Boolean,
				default:false
			},
			shipmentsData: {
				type:Object,
				default:{},
			},
		},
		
		data() {
			return {
				informObject:'本人直接上级',
				informContent:'销售订单已转发指令，请处理（知晓）。',
				countDownNum:3,
				informData:{}
			}
		},
		watch: {
			show: {
				deep: true,
				handler(val) {
					if(val == true){
						this.countDown()
						this.notifyObject()
					}
				}
			}
		
		},
		methods: {
			countDown(){
				let num = this.countDownNum > 0 ? this.countDownNum - 1 : null;
				setTimeout(() => {
					if(num == null){
						return this.close()
					}
					this.countDownNum = num;
					this.countDown();
				}, 1000);						
			},
			moveHandle(){
				return;
			},
			close(){
				this.$emit('close');
			},
			notifyObject(){
				api.sendNoticePage({triggerButton:"1254355793118101504"}).then(res=>{
					if(res.code == 0){
						let { result } = res.data
						this.informData = result
					}
				})
			},
			notification(){
				let id = this.shipmentsData.id
				let No = this.shipmentsData.orderNo
				uni.navigateTo({
					url: '/subcontractList/order/salesAdmin/salesOrder/newsNotification/index?id=' + id + '&orderNo=' + No
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.batch{
		z-index: 10;
		width:100%;
		height: 100vh;
		position: fixed;
		top:0;
		left: 0;
		background: rgba(0,0,0,0.6);
		.disalog-box{
			background-color: white;
			border-radius: 10rpx;
			position: absolute;
			top:50%;
			left: 50%;
			animation-name: disalogshow;
			animation-duration: 0.5s;
			width: calc(100% - 180rpx);
			transform: translate(-50%,-50%);
			box-sizing: border-box;
			padding: 20rpx;
			.title-box{
				position: relative;
				font-size: 28rpx;
				.title{
					font-weight: 700;
					text-align: center;
				}
				.close{
					position: absolute;
					right: 0;
					top: 0;
				}
			}
			.disalog-content{
				margin: 10rpx 0;
				.content-item{
					font-size: 28rpx;
					line-height: 60rpx;
					display: flex;
					&-textarea{
						padding:15rpx;
						box-sizing: border-box;
						margin: 15rpx 0 0 10rpx;
						border: 1rpx solid #d8d8d8;
						width: 400rpx;
						height: 200rpx;
						border-radius: 10rpx;   
					}
				}
			}
			.bottomBtn{
				display: flex;
				align-items: center;
				justify-content: center;
				margin: 30rpx 0;
				&-text{
					font-size: 24rpx;
					padding: 15rpx 25rpx;
					border-radius: 8rpx;
					color: #fff;
					background-color: #66cc33;
				}
			}
			
		}
	}
	@keyframes disalogshow {
		0% {
			transform:translate(-50%,-60%);
			// transform: scale(0);
			opacity: 0;
		}
	
		100% {
			transform: translate(-50%,-50%);
			// transform: scale(1);
			opacity: 1;
		}
	}
</style>
